package com.edu.zx;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

public class Service {
	List<User> users = new ArrayList<User>();
	public Service() {
		ResourceBundle resourceBundle = ResourceBundle.getBundle("com/edu/zx/users");
    	String[] usernames = resourceBundle.getString("user").split(",");
    	String[] passwords = resourceBundle.getString("password").split(",");
    	for(int i = 0; i < usernames.length; i++){
    		users.add(new User(usernames[i], passwords[i]));
    	}
	}
	
	public boolean checkLogin(String username, String password){
		for(User user : users){
			if(user.getUsername().equals(username) && user.getPassword().equals(password)){
				return true;
			}
		}
		return false;
	}
}
